package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpITADShowDocumentsPanelNewPageUtil extends SeleniumPageUtil {
	// the show documents panel page elements
	public final static By ISDP_LINK_NEW = By.id("ctl44_docsControl_btnNew");
	public final static By ISDP_TD_HEADER =  By.xpath("//*[@id='ctl44_pnlDocuments']/table/tbody/tr/td[2]");
	
	// the show documents panel \ new page elements
	public final static By ISDPN_TD_FILE = By.xpath("//*[@id='ctl44_docsControl_FileUploadPanel']/table/tbody/tr[1]/td[1]");
	public final static By ISDPN_INPUT_FILE_UPLOAD = By.id("ctl44_docsControl_FileUpload");
	public final static By ISDPN_TD_TITLE = By.xpath("//*[@id='ctl44_docsControl_FileUploadPanel']/table/tbody/tr[2]/td[1]");
	public final static By ISDPN_INPUT_TITLE = By.id("ctl44_docsControl_FileUploadTitle");
	public final static By ISDPN_TD_KEYWORDS = By.xpath("//*[@id='ctl44_docsControl_FileUploadPanel']/table/tbody/tr[3]/td[1]");
	public final static By ISDPN_INPUT_KEYWORDS = By.id("ctl44_docsControl_FileUploadKeywords");
	public final static By ISDPN_TD_COMMENT = By.xpath("//*[@id='ctl44_docsControl_FileUploadPanel']/table/tbody/tr[4]/td[1]");
	public final static By ISDPN_INPUT_COMMENT = By.id("ctl44_docsControl_FileUploadComment");
	public final static By ISDPN_TD_VISIBILITY = By.xpath("//*[@id='ctl44_docsControl_FileUploadPanel']/table/tbody/tr[5]/td[1]");
	public final static By ISDPN_INPUT_VISIBILITY_0 = By.id("ctl44_docsControl_btnVisibility_0");
	public final static By ISDPN_LABEL_VISIBILITY_0 = By.xpath("//*[@id='ctl44_docsControl_btnVisibility']/tbody/tr[1]/td/label");
	public final static By ISDPN_INPUT_VISIBILITY_1 = By.id("ctl44_docsControl_btnVisibility_1");
	public final static By ISDPN_LABEL_VISIBILITY_1 = By.xpath("//*[@id='ctl44_docsControl_btnVisibility']/tbody/tr[2]/td/label");
	public final static By ISDPN_INPUT_UPLOAD = By.id("ctl44_docsControl_fileUploadSubmit");
	public final static By ISDPN_INPUT_CANCEL = By.id("ctl44_docsControl_fileUploadCancel");
	
	public static void enterITADShowDocumentsPanelNewPage(){
		SpITADDefaultPageUtil.enterITADInventoryManagementDefaultPage();
		SeleniumUtil.click(SeleniumUtil.getCachedElement(SpITADDefaultPageUtil.IIM_LINK_SHOW_DOCUMENTS_PANEL));
		SeleniumUtil.waitForFixedMilliseconds(3000);
		SeleniumUtil.waitOnElements(new By[]{ISDP_LINK_NEW});
		SeleniumUtil.click(SeleniumUtil.getCachedElement(ISDP_LINK_NEW));
		waitForPageToLoad();
	}
	
	public static void waitForPageToLoad() {
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.selectFrame(SpHomePageUtil.HOME_FRAME_CONTENT_NAME);
		SeleniumUtil.waitOnElements(new By[]{
				ISDPN_INPUT_FILE_UPLOAD, ISDPN_INPUT_UPLOAD, ISDPN_INPUT_CANCEL
			});
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(ISDPN_INPUT_FILE_UPLOAD));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(ISDPN_INPUT_UPLOAD));
		SeleniumUtil.isDisplayed(SeleniumUtil.findElement(ISDPN_INPUT_CANCEL));
	}
}
